package com.gyl.gitstudy.controller;


import com.gyl.gitstudy.mapper.userMapper;
import com.gyl.gitstudy.pojo.user;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

@Controller
public class userController {
    @Autowired
    private userMapper userMapper;

    @GetMapping("/userList")
    @ResponseBody
    public List<user> queryUserList(){
        List<user> userList = userMapper.queryUserList();
        return userList;
    }
    @GetMapping("/user")
    public String user(Model model,int id){
        user user = userMapper.userById(id);
        model.addAttribute("user",user);
        return "index";
    }
}
